/*
 * macros.hpp
 *
 *
 * 	Defines macros for cleaner front-end syntax
 *
 *  Created on: Jul 28, 2010
 *      Author: sdaniele
 */

#ifndef MACROS_HPP_
#define MACROS_HPP_


#define process_d(name, ...)						\
	typedef process<								\
				mpl::vector< __VA_ARGS__ >			\
			  , is_thread							\
			 > (name);

#define process(name, backoff, init_arg, ...)		\
	typedef process<								\
				mpl::vector< __VA_ARGS__ >			\
			  , is_thread							\
			  , backoff								\
			  , (init_arg)							\
			 > (name);

#define spawn(p) p
#define name(n) n

#define flops(k)\
		work<k>

#define once\
	once<mpl::placeholders::_1>
#define decr\
	decr<mpl::placeholders::_1>
#define half\
	half<mpl::placeholders::_1>
#define sub(s)\
	sub<mpl::placeholders::_1,mpl::int_<s> >
#define div_by(d)\
	div_by<mpl::placeholders::_1,mpl::int_<d> >

#define JOIN( X, Y ) DO_JOIN( X, Y )
#define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
#define DO_JOIN2( X, Y ) X##Y

#define UNIQUE(str)\
	JOIN(str,__LINE__)


#define run(name)\
	name UNIQUE(instance);	UNIQUE(instance).operator()();		//must be on the same line

#define inject_here()\
	int inject_here_some_unique_name;


#endif /* MACROS_HPP_ */
